package com.qing.qingcodegenerate.model.dto.user;

import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.io.Serializable;

@Data
public class UserRegisterRequest implements Serializable {

    private static final long serialVersionUID = 3191241716373120793L;

    /**
     * 账号
     */
    @Size(min=4, max=16, message = "账号长度必须在4-16位之间")
    @NotBlank(message = "账号不能为空")
    private String userAccount;

    /**
     * 密码
     */
    @Size(min=6, max=16, message = "密码长度必须在6-16位之间")
    @NotBlank(message = "密码不能为空")
    private String userPassword;

    /**
     * 确认密码
     */
    @Size(min=6, max=16, message = "密码长度必须在6-16位之间")
    @NotBlank(message = "密码不能为空")
    private String checkPassword;

    @AssertTrue(message = "密码输入不一致")
    public boolean isValidCode() {
        return userPassword.equals(checkPassword);
    }
}
